package com.yidu.CashManagement.controller;

import com.yidu.BusinessParament.entity.Cash;
import com.yidu.CashManagement.entity.FundsAllot;
import com.yidu.CashManagement.service.FundsAllotService;
import com.yidu.CashManagement.util.CreateId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 苏彬
 * @date 2022/12/10 17:01
 **/
@RestController
public class FundsAllotController {
    @Autowired
    FundsAllotService fundsAllotService;

    /**
     * 查询+分页
     *
     * @param page           当前页
     * @param row            显示数
     * @param allotTime      调拨日期
     * @param allotType      调拨类型
     * @param allotDirection 调拨方向
     * @return Map
     */
    @RequestMapping("/selectFundsAllot")
    public Map selectFundsAllot(int page, int row, String allotTime, @RequestParam(defaultValue = "-1") int allotType, @RequestParam(defaultValue = "-2") int allotDirection) {
        return fundsAllotService.selectFundsAllot(page, row, allotTime, allotType, allotDirection);
    }

    /**
     * 删除
     * @param myArr
     */
    @RequestMapping("/deleteFundsAllot")
    public void deleteExchangeRate(String myArr) {
        fundsAllotService.deleteFundsAllot(myArr);
    }

    /**
     * 新增
     * @param fundsAllot
     */
    @RequestMapping("/addFundsAllot")
    public int addFundsAllot(FundsAllot fundsAllot) {
       return fundsAllotService.addFundsAllot(fundsAllot);
    }

    @RequestMapping("/updateFundsAllot")
    public String updateFundsAllot(FundsAllot fundsAllot) {
        return fundsAllotService.updateFundsAllot(fundsAllot);
    }

    /**
     * 查询现金账户
     * @return
     */
    @RequestMapping("/selectCashOne")
    public Map SelectCash() {
      return fundsAllotService.SelectCash();
    }
    /**
     * 创建Id
     * @param name 需要在前面加的字母
     * @return
     */
    @RequestMapping("/createId")
    public String createId(String name) {
        return  CreateId.createId(name);
    }
}
